package com.zb.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWorkEngineerSignAnnex;
import com.zb.mapper.ZjWorkEngineerSignAnnexMapper;
import com.zb.service.ZjWorkEngineerSignAnnexService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 工程师签到附件表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2024-03-19
 */
@Service
public class ZjWorkEngineerSignAnnexServiceImpl extends ServiceImpl<ZjWorkEngineerSignAnnexMapper, ZjWorkEngineerSignAnnex> implements ZjWorkEngineerSignAnnexService {

    // 保存拍照签到附件
    @Override
    public void save(Long custAccId, Long workId, Long workEngineerSignId, List<String> paths) {
        if (CollectionUtil.isEmpty(paths)) {
            return;
        }
        List<ZjWorkEngineerSignAnnex> annexList = new ArrayList<>();
        ZjWorkEngineerSignAnnex signAnnex = null;
        for (String path : paths) {
            signAnnex = new ZjWorkEngineerSignAnnex();
            signAnnex.setId(IdWorker.getId());
            signAnnex.setCustAccId(custAccId);
            signAnnex.setWorkId(workId);
            signAnnex.setWorkEngineerSignId(workEngineerSignId);
            signAnnex.setPath(path);
            annexList.add(signAnnex);
        }
        this.saveBatch(annexList);
    }
}
